package com.xuecheng.order.controller;

import com.xuecheng.commons.model.dto.CourseOrdersDto;
import com.xuecheng.commons.model.dto.PageRequest;
import com.xuecheng.commons.model.dto.CourseOrdersDto;
import com.xuecheng.commons.model.dto.PageRequest;
import com.xuecheng.commons.model.vo.ResponseResult;
import com.xuecheng.order.config.ExcelUtil;
import com.xuecheng.order.domain.Orders;
import org.checkerframework.checker.units.qual.A;
import org.springframework.web.bind.annotation.*;
import com.xuecheng.order.service.OrdersService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * <p>
 * 订单前端控制器
 * </p>
 *
 * @author itheima
 */
@Slf4j
@RestController
public class OrdersController {

    @Autowired
    private OrdersService  ordersService;


    // 用户下单
    @PostMapping("/orders/create/{coursePubId}")
    public ResponseResult createOrder(@PathVariable("coursePubId")Long coursePubId){
        return ordersService.createOrder(coursePubId);
    }

    // 查询支付结果
    @GetMapping("/orders/{orderNo}")
    public ResponseResult findPay(@PathVariable("orderNo") String orderNo){
        return ordersService.findPay(orderNo);
    }

    //查询个人订单
    @PostMapping("/orders/my-list")
    public ResponseResult Myorders(PageRequest params, @RequestBody CourseOrdersDto dto){

        return ordersService.Myorders(params,dto);
    }

    //查询订单
    @PostMapping("/orders/org-list")
    public ResponseResult findOrders(PageRequest params, @RequestBody CourseOrdersDto dto) {
        //调用service返回
        return ordersService.findOrders(params, dto);
    }

    @Autowired
    private ExcelUtil excelUtil;

    //生成Excel文件
    @GetMapping("/orders/order/excel")
    public ResponseResult Excel(Long companyId) {
        //返回结果
        return ordersService.Excel(companyId);
    }
    /*//查询个人订单
    @PostMapping("/orders/my-list")
    public ResponseResult Myorders(PageRequest params, @RequestBody CourseOrdersDto dto){

        return ordersService.Myorders(params,dto);
    }*/


}
